﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using Costella;

namespace THO7_Team8
{
	internal class PlateDetector : VisionAlgorithm
	{
		public PlateDetector(String name)
			: base(name)
		{
		}

		public override System.Drawing.Bitmap DoAlgorithm(System.Drawing.Bitmap img)
		{
			Bitmap newImg = (Bitmap) img.Clone();
			//int[] imageArray = MyImage.BmpToArray();
			//newImg = new Greyscale("lkahflkjdsgf").DoAlgorithm(new Bitmap(newImg).ToPixmap().ToAycc()[1].ToPixmap<double>(z => z).SobelMagnitude().ToPixmap<byte>(z => 2 * z > 255 ? (byte)255 : (byte)Math.Round(2 * z)).ToBitmap());
			BlobDetector bd = new BlobDetector(img, newImg);
			bd.findBlobs();

			//int[] blobCounts = new int[0];
			//bd.removeSmallBlobs(500, ref bd.labeledImage, ref blobCounts);
			//Point[][] candidates = bd.findCandidates(ref blobCounts);

			//Bitmap[] candidates2 = bd.getLicensePlates(candidates);

			return bd.drawNewPictureAllBlobs();//candidates2[6];

			//return bd.drawNewPictureAllBlobs();
		}
	}
}